using System;
using VitCode.Castle.Entities;

namespace AMS.Core.Importors
{
    public class ImportorFactory
    {
        private ImportorFactory()
        {
        }

      
        public static AbstractImportor ImportorInstance(string filePath, string sheetName, string userGroupName,User currentUser)
        {

            string strFileName = filePath;
            int index = strFileName.LastIndexOf("\\");
            strFileName = strFileName.Substring(index + 1, strFileName.Length - index - 1);
            strFileName = strFileName.ToUpper();
            if (strFileName.IndexOf("??????????") >= 0)
            {
                return new SiteImportor(filePath, sheetName, currentUser);
            }
            else if (strFileName.IndexOf("?????????") >= 0)
            {
                return new AssetImportor(filePath, sheetName, currentUser, "MainAsset");
            }
            else if(strFileName.IndexOf("???????????") >= 0)
            {
                return new AssetImportor(filePath, sheetName, currentUser, "LowValueAsset");
            }
            else if (strFileName.IndexOf("???????????") >= 0)
            {
                return new AssetImportor(filePath, sheetName, currentUser, "StorageAsset");
            }
            else if (strFileName.IndexOf("?????????????") >= 0)
            {
                return new AssetImportor(filePath, sheetName, currentUser, "SubAsset");
            }
            else if (strFileName.IndexOf("???????????") >= 0)
            {
                return new DepartmentImportor(filePath, sheetName, currentUser);
            }
            else if (strFileName.IndexOf("??????????") >= 0)
            {
                return new UserImportor(filePath, sheetName, currentUser);
            }
            else if (strFileName.IndexOf("?????????????") >= 0)
            {
                return new AssetTypeImportor(filePath, sheetName, currentUser);
            }
            else
                throw new ArgumentOutOfRangeException("????Excel????????????", "LanguageKeyWord_00831???????????LanguageKeyWord_00832????????????????");
        }
    }
}
